#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2010 Boštjan Seničar
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pango
#import pygtk
import gtk

class hex_view:
	
	def __init__(self,parent,row):
		self.parent = parent		
		self.show_hexview(self.parent.profile.tag_data(row))
		
		self.parent.frame_label.set_text("<b>Private or unkown tag</b>")
		self.parent.frame_label.set_use_markup(True)
	
	def show_hexview(self, data=None):
		
		child = self.parent.wTree.get_object("hexview")
		hex_text = self.parent.wTree.get_object("hex_text")
		hex_buffer = self.parent.wTree.get_object("hex_buffer")		
					
		text, extra_chars = self.parent.bytes_to_hexview(data)
				
		hex_buffer.set_text(text[0:-extra_chars]);
		#line_num_buffer.set_text(text[:-2]);
		font = pango.FontDescription("monospace")
		hex_text.modify_font(font)
		hex_text.set_wrap_mode(gtk.WRAP_NONE)
		
		self.parent.replace_child(child)